import {defineConfig} from "vite";
import uni from "@dcloudio/vite-plugin-uni";

const {appid} = require('./build/index.js')

import fs from 'fs'
import {fileURLToPath, URL} from "node:url";

const {parse, stringify} = require('comment-json')
const manifestPath = `${__dirname}/manifest.json`
const manifest = parse(fs.readFileSync(manifestPath, {encoding: 'utf-8'}).toString())

manifest['mp-weixin'].appid = appid

fs.writeFileSync(manifestPath, stringify(manifest), {encoding: 'utf-8'})

export default defineConfig({
  build: {
    sourcemap: true,
  },
  plugins: [
    uni(),
  ],
  define: {},
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url))
    }
  }
});
